package com.yicong.ants.view.dialog;


import android.content.Context;
import android.content.DialogInterface;
import android.view.View;

import androidx.fragment.app.FragmentManager;

import com.cchao.simplelib.core.UiHelper;
import com.yicong.ants.R;
import com.yicong.ants.utils.DisplayUtils;

public class TransferTipsDialog extends BaseNiceDialog implements View.OnClickListener {
    private TransferTipsInfo info;
    private DialogInterface.OnClickListener listener;

    public static TransferTipsDialog newInstance(Context context,TransferTipsInfo info) {
        TransferTipsDialog dialog = new TransferTipsDialog(info);
        dialog.setWidth(DisplayUtils.px2dp(context, (float) (UiHelper.getScreenWidth() * 0.9)))
                .setOutCancel(false)
                .setDimAmount(0.3f);
        return dialog;
    }

    public TransferTipsDialog(TransferTipsInfo info) {
        this.info = info;
    }

    public void setOnClickListener(DialogInterface.OnClickListener listener){
        this.listener = listener;
    }

    @Override
    public int intLayoutId() {
        return R.layout.dialog_transfer_tips;
    }

    @Override
    public void convertView(NiceViewHolder holder, BaseNiceDialog dialog) {
        holder.setText(R.id.title , info.title);
        holder.setText(R.id.number , info.number);
        holder.setText(R.id.name , info.name);
        holder.setText(R.id.phone , info.phone);
        holder.setText(R.id.wx_number , info.wx_number);
        holder.setText(R.id.tips , info.tips);
        holder.setOnClickListener(R.id.iv_exit, this);
        holder.setOnClickListener(R.id.close, this);
        holder.setOnClickListener(R.id.tv_sure, this);
    }

    @Override
    public void onClick(View v) {
        dismiss();
        if (v.getId() == R.id.iv_exit) {
            dismiss();
        }else if (v.getId() == R.id.close){
            dismiss();
        }else if (v.getId() == R.id.tv_sure){
            dismiss();
            if (listener!=null){
                listener.onClick(null , 0);
            }
        }
    }

    public static class TransferTipsInfo {
        public String title;
        public String number;
        public String name;
        public String phone;
        public String wx_number;
        public String tips;
    }
}
